package com.example.mybatis;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator on 2017/1/12 0012.
 */

//mybatis-spring-boot-starter 1.1.1


@Mapper
public interface DemoMapper {

    @Select("select *from Demo where name like concat('%',#{name},'%')")
//    @Select("select *from Demo where name =#{name}")
    public List<Demo> likeName(String name);

    @Select("select *from Demo where id = #{id}")
    public Demo getById(long id);

    @Select("select name from Demo where id = #{id}")
    public String getNameById(long id);

    @Insert("insert into Demo(name) values(#{name})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    public long save(Demo demo);

//    useCache=true，
//    flushCache=false，
//    resultSetType=FORWARD_ONLY，
//    statementType=PREPARED，
//    fetchSize= -1，timeout=-1 ，
//    useGeneratedKeys=false ，
//    keyProperty=”id“。

}
